<template>
	<view class="uwo-autograph">
		<view class="uni-px-8 uni-py-4 solid uni-primary text-df uni-radius-lg" @click="show">
			<slot>
				<text class="">点击签名</text>
			</slot>
		</view>
		<view v-if="modelValue.url || modelValue.path" class="">
			<image
				@click="previewImg(modelValue.url || staticUrl + modelValue.path)"
				style="width: 200rpx; height: 100rpx"
				:src="modelValue.url || staticUrl + modelValue.path"
				mode="aspectFit"
			></image>
		</view>
		<uwo-autograph-modal ref="autographModal" @ok="handleOk"></uwo-autograph-modal>
	</view>
</template>
<script setup>
import { ref } from 'vue';
import { getEnv } from '@/common/config';
const staticUrl = getEnv().API_URL_STATIC;
const autographModal = ref();

const props = defineProps({
	// 绑定值
	modelValue: {
		type: Object,
		default() {
			return {};
		}
	}
});
const emits = defineEmits(['update:modelValue']);
const show = () => {
	autographModal.value.show();
};
const handleOk = (result) => {
	emits('update:modelValue', result);
};
const previewImg = (url) => {
	uni.previewImage({
		urls: [url]
	});
};
</script>
<style scoped lang="scss">
.uwo-autograph {
}
</style>
